<!DOCTYPE html>
<html lang="en">

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
		<meta name="Generator" content="EditPlus®">
		<meta name="Author" content="梦想星辰大海">
		<meta name="Keywords" content="">
		<meta name="Description" content="">
		<title>cms后台模板</title>
		<link rel="stylesheet" href="${BASE_PATH}/static/book/res/lib/layui/css/layui.css">
	</head>

	<body>
		<form id="ff" method="post">
			<input id="txt-p" type="hidden" name="p" value="${pageVo.pageNum}"/>
			<div class="layui-form-item">
		    	<div class="layui-inline">
		     		<label class="layui-form-label" style="padding: 9px 15px;width: 56px;">图书编号</label>
	      			<div class="layui-input-block" style="margin-left: 90px;width: 300px;">
		        		<input type="text" name="number" value="${searchVo.number}" autocomplete="off" class="layui-input" onclick="layui.laydate({elem: this})">
	      			</div>
	    		</div>
		    	<div class="layui-inline">
			      	<label class="layui-form-label" style="padding: 9px 15px;width: 30px;">书名</label>
			      	<div class="layui-input-inline" style="width: 300px;">
			        	<input type="text" name="name" value="${searchVo.name}" autocomplete="off" class="layui-input">
			      	</div>
		    	</div>
		    	<div class="layui-inline">
			      	<label class="layui-form-label" style="padding: 9px 15px;width: 30px;margin-left: 30px;">作者</label>
			      	<div class="layui-input-inline" style="width: 300px;">
			        	<input type="text" name="author" value="${searchVo.author}" autocomplete="off" class="layui-input">
			      	</div>
		    	</div>
		    	<div class="layui-inline">
			      	<label class="layui-form-label" style="padding: 9px 15px;width: 42px;margin-left: -22px;">出版社</label>
			      	<div class="layui-input-inline" style="width: 300px;">
			        	<input type="text" name="press" value="${searchVo.press}" autocomplete="off" class="layui-input">
			      	</div>
		    	</div>
		    	<div class="layui-inline">
			      	<button class="layui-btn">确认</button>
			 	</div>
		 	</div>
		</form>  
		<div class="layui-form">
			<table class="layui-table" lay-skin="line">
				<colgroup>
					<col width="100">
					<col width="100">
					<col width="100">
					<col width="100">
					<col width="200">
					<col width="200">
					<col width="150">
					<col width="120">
					<col width="80">
					<col width="200">
					<col>
				</colgroup>
				<thead>
					<tr>
						<th><input type="checkbox" name="" lay-skin="primary" lay-filter="allChoose"></th>
						<th>图书编号</th>
						<th>书名</th>
						<th>作者</th>
						<th>出版社</th>
						<th>在馆数量</th>
					</tr>
				</thead>
				<tbody>
					[#list pageVo.list as book]
					<tr>
						<td><input type="checkbox" name="indexs" value="${book_index}" lay-skin="primary"></td>
						<td>${book.number}</td>
						<td>${book.name}</td>
						<td>${book.author}</td>
						<td>${book.press}</td>
						<td>${book.librarieNumber}</td>
		    		</tr>
		    		[/#list]
		  		</tbody>
			</table> 
  		</div>
	  	<div id="demo1"></div>
	</body>
	<script type="text/javascript " src="${BASE_PATH}/static/book/res/lib/layui/layui.js"></script>
	<script>
	
	layui.use(['laypage', 'layer', 'form'], function(){
		var currBookList=[];
		[#list pageVo.list as book]
			currBookList.push({
			 	bookId:${book.bookId},
				cateId:${book.cateId},
				number:'${book.number}',
				urlPic:'${book.urlPic}',
				name:'${book.name}',
			 	author:'${book.author}',
				press:'${book.press}',
				librarieNumber:${book.librarieNumber},
				totalQuantity:${book.totalQuantity}
			});
		[/#list]//蒙版
	  var $ = layui.jquery;
	  var form = layui.form();
	  var laypage = layui.laypage;
	  
	  //全选
	  form.on('checkbox(allChoose)', function(data){
	    var child = $(data.elem).parents('table').find('tbody input[type="checkbox"]');
	    child.each(function(index, item){
	      item.checked = data.elem.checked;
	    });
	    form.render('checkbox');
	  });
	  
	  
	  //分页
		laypage({
			cont: 'demo1'
			,pages: ${pageVo.pageCount} //总页数
			,curr: ${pageVo.pageNum}
			,groups: 5 //连续显示分页数
			,jump: function(obj, first) {
				if(first===true){
					return ;
				}
				var curr = obj.curr;
				console.dir(curr);
				$("#txt-p").val(curr);
				//得到了当前页，用于向服务端请求对应数据
				$("#ff").submit();
				
			}
		});
		//获取选择的数据
		function selectData(){
			var dataArr=[];
		  	$("input[name=indexs]:checked").each(function(){
		  		var index=$(this).val();
		  		dataArr.push(currBookList[index]);
		  	});
		 	return dataArr;
		}
		//获取选择的ID
		function selectIds(){
			var ids=[];
		  	$("input[name=indexs]:checked").each(function(){
		  		var index=$(this).val();
		  		ids.push(currBookList[index].bookId);
		  	});
		 	return ids;
		}
		window.selectData=selectData;//有数据获取数据
	  	window.selectIds=selectIds;//有ID获取ID
	});
	</script>

</html>